/**
 * 
 */
package com.demo.test.rpc.api.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.bluering.inf.entity.PageEntity;
import com.bluering.inf.entity.RespEntity;
import com.demo.test.repository.model.OcsIssuer;
import com.demo.test.repository.model.OcsSysUser;
import com.demo.test.rpc.api.IDbTest;
import com.demo.test.service.IOcsIssuerService;
import com.demo.test.service.IOcsSysUserService;
import com.github.pagehelper.PageInfo;

/**
 * @author CaoHenghui
 *
 */

@Service
public class DbTestImpl implements IDbTest {
	
	@Autowired
	private IOcsIssuerService iOcsIssuerService;
	
	@Autowired
	private IOcsSysUserService iOcsSysUserService;

	/* (non-Javadoc)
	 * @see com.demo.test.rpc.api.IDbTest#getAllIssuer()
	 */
	@Override
	public RespEntity<List<OcsIssuer>> getAllIssuer() {
		OcsIssuer record = new OcsIssuer();
		List<OcsIssuer> list = iOcsIssuerService.selectAll(record);
		return new RespEntity<List<OcsIssuer>>("1000","ok",list);
	}

	/* (non-Javadoc)
	 * @see com.demo.test.rpc.api.IDbTest#queryByMobile(java.lang.String, java.lang.String)
	 */
	@Override
	public RespEntity<OcsSysUser> queryByMobile(String mobile, String username) {
		// TODO Auto-generated method stub
		OcsSysUser user = iOcsSysUserService.queryByMobile(mobile, username);
		return new RespEntity("1000","ok",user);
	}
	
	public PageEntity<OcsSysUser> selectByPage(int pageIndex,int pageSize) {
		// TODO Auto-generated method stub
		PageInfo<OcsSysUser> pageInfo = iOcsSysUserService.selectByPage(pageIndex, pageSize, new OcsSysUser());
		List<OcsSysUser> list  =  pageInfo.getList();
		PageEntity<OcsSysUser> page = new PageEntity<OcsSysUser>();
		page.setCode("1000");
		page.setMessage("ok");
//		page.setTotalCount((int)pageInfo.getTotal());
		page.setPage(pageIndex);
		page.setLength(pageSize);
		page.setDataList(list);
		return page;
	}

}
